package cn.tk.repository.mr;

import cn.tk.model.entity.mr.EntityValue;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by denglw on 2021/8/7.<br/>
 * Desc: 实体值dao
 */
@Repository
public interface EntityValueDao extends JpaRepository<EntityValue, Long> {

    /**
     * 获取唯一值
     * @param id id
     * @return 值记录
     */
    @Override
    @Query(value = "select * from mr_entity_value where id=?1 and deleted=0", nativeQuery = true)
    EntityValue getOne(Long id);

    /**
     * 获取实体的值列表.<br/>
     * @param entityId 实体id
     * @return 值列表
     */
    @Query(value = "select * from mr_entity_value where entity_id=?1 and deleted=0", nativeQuery = true)
    List<EntityValue> findEntityValues(Long entityId);
}
